package qsc.algorithm.DFS;

/**
 * @auther QiuShangcheng
 * @create 2021/4/30
 */
public class Dfs {
    /**
     *
     * @param graph 图
     * @param i 对应{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'}的开始位置，以0为第一位
     */
    public static void dfs(Graph graph ,int i){
        System.out.print(" "+graph.getVertex()[i]+"("+i+")"+"-->");
        graph.getVisited()[i] = true;
        int[] link = graph.getMatrix()[i];
        for (int j = 0; j < graph.getVertex().length; j++) {
            if (link[j] == 1 && graph.getVisited()[j] == false){
                dfs(graph,j);
            }

        }
    }
}
